package compiler;
/*
 *
 * CSymbol
 *
 *	RESERVED
 *	CONST
 *	TYPE
 *	VAR
 *	PROCEDURE
 *	PRORGRAM
 *	ARG
 */
abstract class CSymbol
{
	int level;
	CSymbol(int l) { level = l; }
}

/*
 *
 * CProgram
 *
 *
 */
class CProgram extends CSymbol
{
	CProgram() { super(0); }
	public String toString()
	{
		return "Program identifier";
	}
}


/*
 *
 * CConst
 *
 */
abstract class CConst extends CSymbol implements Cloneable
{
	CConst(int l) {	super(l); }
	abstract int GetIntVal();

	public Object clone()
	{
		try
		{
			CConst cs = (CConst)super.clone();
			cs.level = level;
			return cs;
		}
		catch (CloneNotSupportedException e)
		{
	    // this shouldn't happen, since we are Cloneable
			throw new InternalError();
		}
    }

}

class CIntConst extends CConst
{
	int val;
	CIntConst(int l, int v)
	{
		super(l);
		val = v;
	}

	int GetIntVal() { return val; }

	public Object clone()
	{
		//try
		//{
			CIntConst ic = (CIntConst)super.clone();
			ic.val = val;
			return ic;
		//}
		//catch (CloneNotSupportedException e)
		//
	    // this shouldn't happen, since we are Cloneable
			//throw new InternalError();
		//}
    }
	public String toString()
	{
		return "Integer const " + val + " (Level "+ level + ")";
	}
}

class CBoolConst extends CConst
{
	boolean val;
	CBoolConst(int l, boolean v)
	{
		super(l); val = v;
	}

	int GetIntVal() { return (val)? 1: 0; }

	public Object clone()
	{
		//try
		//{
			CBoolConst bc = (CBoolConst)super.clone();
			bc.val = val;
			return bc;
		//}
		//catch (CloneNotSupportedException e)
		//{
	    // this shouldn't happen, since we are Cloneable
			//throw new InternalError();
		//}
    }
	public String toString()
	{
		return "Boolean const " + val + " (Level "+ level + ")";
	}
}


class CSymbolItem
{
	CSymbol info;
	public CSymbolItem next = null;
	CSymbolItem(CSymbol s)
	{
		info = s;
	}

	CSymbolItem(CSymbol s, CSymbolItem item)
	{
		info = s; next = item;
	}
}
